package com.ophiux.cs.application.consultOrder.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ophiux.cs.application.consultOrder.dto.UpdateCSOrderRecordsRequest;
import com.ophiux.cs.application.consultOrder.dto.UpdateCSOrderRecordsResponse;
import com.ophiux.cs.application.consultOrder.service.IUpdateCSOrderRecordsAppService;
import com.ophiux.cs.application.core.Result;
import com.ophiux.cs.application.core.ResultEnum;
import com.ophiux.cs.domain.consultOrder.model.entity.CSOnlineRecords;
import com.ophiux.cs.infrastructure.repositories.consultOrder.CSOnlineRecordRepository;

import lombok.extern.slf4j.Slf4j;


@Service
@Slf4j
public class UpdateCSOrderRecordsAppService implements IUpdateCSOrderRecordsAppService {
	@Autowired
	CSOnlineRecordRepository cSOnlineRecordRepository;

	@Override
	public Result<UpdateCSOrderRecordsResponse> updateCSOrderRecord(UpdateCSOrderRecordsRequest dto) {
		UpdateCSOrderRecordsResponse resp = new UpdateCSOrderRecordsResponse();
		try {
			if(!dto.isParamValid()) {
				return Result.fail(ResultEnum.requestParamFail);
			}
			
			CSOnlineRecords obj = new CSOnlineRecords();
			obj.setRECORD_ID(dto.getRECORD_ID());
			obj.appriaseYes();
			cSOnlineRecordRepository.update(obj);
			
		} catch (Exception e) {
			log.info("程序异常：",e);
			e.printStackTrace();
			return Result.fail(ResultEnum.requestException);
		}
		return Result.success(resp);
	}

}
